package com.changli07._interface.exer2;

public class ComparableCircle extends Circle implements CompareObject{
    public ComparableCircle() {
    }

    public ComparableCircle(double radius) {
        super(radius);
    }

    @Override
    public int compareTo(Object o) {
        if(o == this){
            return 0;
        }
        if( o instanceof ComparableCircle){
            ComparableCircle c = (ComparableCircle)o;
//            return Double.compare(this.radius,c.radius);
            if (this.radius> c.radius){
                return 1;
            }
            else if(this.radius<c.radius){
                return -1;
            }
            else {
                return 0;
            }
        }
        else{
//            return 1;
            throw new RuntimeException("输入类型不匹配");
        }
    }
}
